home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1995 April / Internet Tools.iso / dos_win / winsock / maillist / 93-10.Z / 93-10 / text0207.txt < prev    next >
Encoding:
Text File  |  1993-10-18  |  7.4 KB  |  176 lines

  1. >> >       WinSock related question:
  2. >> >          Does WSAGetLastError() return 0 when the last WinSock call
  3. >> >       was successful?
  4. >> >   
  5. >> >          Bob Quinn of FTP Software thinks that calling it without a
  6. >> >   SOCKET_ERROR return from a function is against the 1.1 spec...
  7. >> 
  8. >> Specifically, in a private message to Ian I cited the fact that
  9. >> the v1.1 specification does not explicitly say WSAGetLastError()
  10. >> can be used to indicate the success of the previous function.  It
  11. >> says "this function returns the last network error that occurred.
  12. >> When a particular Windows Sockets API function indicates that an
  13. >> error has occurred, this function should be called to retrieve the
  14. >> appropriate error code."
  15.  
  16. I believe that there was unanimity during the design meetings that a
  17. successful call would _not_ modify the internal error variable accessed
  18. via WSAGetLastError(). The intention was to mirror the semantics of the
  19. Unix "errno" variable - indeed it is possible to #define errno as a
  20. call to WSAGetLastError() in certain circumstances.  And errno is
  21. definitely _not_ cleared on a successful call. Here's the text from
  22. "man -s 2 intro". (This will probably call down USL lawyers on my
  23. head...:-) The final sentence is the key.
  24.  
  25.      This section describes all of the  system  calls.   Most  of
  26.      these calls have one or more error returns.  An error condi-
  27.      tion is indicated by an otherwise impossible returned value.
  28.      This is almost always -1 or the NULL pointer; the individual
  29.      descriptions specify the details.  An error number  is  also
  30.      made available in the external variable errno.  errno is not
  31.      cleared on successful calls, so it  should  be  tested  only
  32.      after an error has been indicated.
  33.  
  34. >> The most significant reason *not* to use WSAGetLastError() after
  35. >> a function succeeds, though, is that it's unnecessary.  It incurs
  36. >> useless overhead.  Why would an application call WSAGetLastError()
  37. >> to see if a function succeeded when every function indicates success
  38. >> with its return code???
  39.  
  40. Wrong. The "most significant reason *not* to use WSAGetLastError()
  41. after a function succeeds" is that the call would reflect the most
  42. recent error from a failing call. In other words, the successful
  43. function call would appear to have failed! (Actually, I'm sure Bob
  44. meant to say this, but his language suggested that maybe after all it
  45. was just a question of efficiency. It isn't.)
  46.  
  47. Geoff
  48. From dob@tis.inel.gov  Fri Oct 15 18:43:56 1993
  49. Received: from mica.inel.gov by SunSITE.unc.edu (SMI4.1/FvK 1.02)
  50.           id AA26458; Fri, 15 Oct 93 18:43:56 EDT
  51. Received: from dewey.inel.gov (dewey.tis.inel.gov) by mica.inel.gov
  52.     (4.1/INEL-MH-10.0) id AA19946; Fri, 15 Oct 93 16:43:04 MDT
  53. Received: by dewey.inel.gov (5.65/INEL-WKS-2.0)
  54.     id AA18822; Fri, 15 Oct 1993 16:43:14 -0600
  55. Date: Fri, 15 Oct 1993 16:43:14 -0600
  56. From: dob@tis.inel.gov (Dave Brooks)
  57. Message-Id: <9310152243.AA18822@dewey.inel.gov>
  58. To: M.J.Cox@bradford.ac.uk, winsock@sunsite.unc.edu
  59. Subject: More than one ASYNCGETHOSTBYNAME?
  60. In-Reply-To: <1993Oct15.075319.9241@bradford.ac.uk>
  61. References: <1993Oct15.075319.9241@bradford.ac.uk>
  62.  
  63. Mark Cox writes:
  64.  > We were playing with winsock code last night and wrote a bit that
  65.  > did a gethostbyname for both the socket and peer.   If we fire up
  66.  > two asyncgethostbyname's they strangely both return the same handle
  67.  > and only one ever completes.
  68.  
  69. I suspect that could be a problem with Lanera.  I fire up multiple
  70. WSAAsynchGetHostByName's from several commercial stacks; the handles have
  71. always been kept straight and they do eventually return.
  72.  
  73.  > Does this mean that you can only do one non-blocking gethostbyname
  74.  > at once,  or is it that the Lanara (demo) Winsock has a problem?  We
  75.  > looked in the Winsock spec but couldn't find anything to say that
  76.  > doing more than one wasn't possible.
  77.  
  78. You can do more than one at a time; I suspect the limitation on the total #
  79. of simultaneous calls is vendor specific and/or related to available
  80. resources at the time of the call.
  81.  
  82. Let's see, the spec says WSAEWOULDBLOCK means that the asynchronous call
  83. cannot complete at this time due to resource or other WinSock restraints.
  84. So, they do tell you if you try to start up more asynchronous calls than
  85. can be handled for whatever reason.  Hm, I'll have to deal with that in my
  86. code as an opportunity to 'try again later', though right now I treat it as
  87. an error.
  88.  
  89. It's true that the spec doesn't spell out some things about doing it 'the
  90. right way'.  I posted a few months ago about multiple
  91. WSAAsynchGetHostByName's, and the overwhelming response from vendors was
  92. that you use a separate hostent buffer for each concurrent call, but other
  93. than that they are supposed to work correctly.  I attended WinSockathon III
  94. in August and brought up the point that this wasn't clearly documented, if
  95. at all; they agreed and indicated that it should be cleared up in the next
  96. release of the spec.  Ok, that's my interepretation, not a commitment on
  97. their part; but that's how I took it.
  98.  
  99. Sorry, I have no idea when the next issue of the spec will be.  Since I
  100. don't work for a vendor I'm not in that process :-)
  101.  
  102. Dave
  103.  
  104. -------------------------------------------------------
  105. David L. Brooks
  106. Idaho National Engineering Lab.  INTERNET: dob@INEL.GOV
  107. POB 1625                         Phone: (208) 526-0826
  108. Idaho Falls, Id. 83415-3730     FAX:   (208) 526-9908
  109. -------------------------------------------------------
  110. From alun@huey.wst.com  Fri Oct 15 18:57:53 1993
  111. Received: from huey.wst.com by SunSITE.unc.edu (SMI4.1/FvK 1.02)
  112.           id AA27082; Fri, 15 Oct 93 18:57:53 EDT
  113. Received: by huey.wst.com (4.1/SMI-4.1)
  114.     id AA11735; Fri, 15 Oct 93 17:59:41 CDT
  115. From: alun@huey.wst.com (Alun Jones)
  116. Message-Id: <9310152259.AA11735@huey.wst.com>
  117. Subject: Re: Tom Nemeth's apparent confusion with the new winpkt.
  118. To: winsock@sunsite.unc.edu
  119. Date: Fri, 15 Oct 93 17:59:41 CDT
  120. X-Mailer: ELM [version 2.3 PL11]
  121.  
  122. Tom Nemeth said:
  123. > Peter Tattam said:
  124. > >>So to modify your installation you need to do the following...
  125. > >>change all lines of the form
  126. > >>    winpkt <winpkt_vector> <normal_vector>
  127. > >>to
  128. > >>    winpkt <normal_vector>
  129. > >>e.g.
  130. > >>    winpkt 0x60 0x61
  131. > >>becomes
  132. > >>   winpkt 0x61
  133. > One big problem with this:  if you have multiple packet drivers loaded
  134. > (ie. 2 network cards) how do you attach a winpkt to the second card?
  135. > I think you should put the second parameter back to the way it was, so
  136. > you would then have:
  137. >     * TOTAL downwards compatibility with previous versions, and
  138. >     * ability to support multiple network cards.
  139.  
  140. It appears you have become confused.  The vector that you pass to
  141. winpkt is the vector that your packet driver is loaded at.  The
  142. removed parameter (which WAS the first one) specified a NEW address
  143. that the winpkt program would run on.  The up-to-date version CAN be
  144. used with more than one card:
  145.  
  146. ne2000 0x61 3 320
  147. 3c509 0x73 5 300
  148. (for example)
  149. To load winpkt on the 3c509:
  150. winpkt 0x73
  151. To load it on the ne2000:
  152. winpkt 0x61
  153. (And there's nothing stopping you from doing both, if I'm not very
  154. much mistaken!)
  155.  
  156. > Please consider!
  157.  
  158. Please consider that I much like this new version - you simply have to
  159. find ONE interrupt vector that's unused, rather than two (and having
  160. to make sure for some programs that the winpkt vector was lower than
  161. the non-winpkt!)  I would guess a neat feature would be to remove the
  162. one remaining parameter to load onto the first (non-winpkted) packet
  163. driver!
  164.  
  165. > Tom Nemeth
  166.  
  167. Alun.
  168. ~~~~
  169.  
  170.  
  171.  
  172.